package com.xiaojie.mapper;

import com.xiaojie.pojo.Orders;
import com.xiaojie.pojo.User;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName UserMapper
 * @Author jiege
 * @Date 2021/5/6 20:30
 **/
public interface OrdersMapper {

    //查询订单的同时还查询该订单所属的用户
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "ordertime",column = "ordertime"),
            @Result(property = "total",column = "total"),
            @Result(property = "user",column = "uid",javaType = User.class,one = @One(select = "com.xiaojie.mapper.UserMapper.findUserById"))

    })
    @Select("select * from orders")
    public List<Orders> findOrderAndUser();

    @Select("select * from orders where uid = #{uid}")
    public List<Orders> findOneByUid(Integer uid);
}
